﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using U.B.ErrorCode;
using U.B.WriteApi.Command;
using U.B.WriteApi.CommandHander;

namespace U.B.WriteApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class AddroleController : ControllerBase
    {
        private readonly IMediator mediator;

        public AddroleController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 添加角色
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public  Task<ApiResult<object>> AddRole(AddRoleCommand request)
        {
            return mediator.Send(request);
            
        }
        /// <summary>
        /// 删除角色
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<object>> deleteRole(DelRoleCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 更新角色
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<object>> updateRole(UpdateroleCommand request)
        {
             return mediator.Send(request);
        }
    }
}
